package com.crm.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.crm.base.ResponseResult;
import com.crm.domain.entity.Clue;
import com.crm.domain.query.ClueQuery;
import com.crm.service.ICluePoolService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/clues")
public class CluePoolController {

    private final ICluePoolService cluePoolService;

    @GetMapping("clue/pool")
    public ResponseResult clueList(ClueQuery query){
        Page<Clue> queryPage = cluePoolService.queryPage(query);
        return ResponseResult.success()
                .put("total", queryPage.getTotal())
                .put("rows", queryPage.getRecords())
                .put("parms",null);

    }

    /**
     * 捞取线索
     * @return
     */
    @PutMapping("/clue/gain")
   public ResponseResult updateCluePool (){
        cluePoolService.update();
        return ResponseResult.success();
    }
}
